package zhishu.iceyyy.com.kd_khd.api;

import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import zhishu.iceyyy.com.kd_khd.http.Okhttp;


/**
 * Created by 他的猫 on 2017/5/10.
 */

public class API {

    public static final String Base = "http://47.92.127.40:8080/api";


    /**
     * 登录
     *
     * @param phonenum
     * @param password
     * @param handler
     */
    public static void login(String phonenum, String password, Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("userName", phonenum);
        map.put("password", password);
        map.put("type", "login");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 个人中心
     *
     * @param handler
     */
    public static void personal(String deliveryUid, Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("deliveryUid", deliveryUid);
        map.put("type", "personal");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 轮播图
     *
     * @param handler
     */
    public static void photoSet(Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("type", "photoSet");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 编号查询
     *
     * @param handler
     */
    public static void deliverSearch(String deliveryCode, Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryCode", deliveryCode);
        map.put("type", "deliverSearch");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 问题件提醒
     * http://localhost:8080/api?deliveryUid=2&type=errorDeliver
     */
    public static void errorDeliver(String deliveryUid, Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryUid", deliveryUid);
        map.put("type", "errorDeliver");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 物流痕迹（查询页面调用的）
     */
    public static void deliveryTrace(String deliveryCode, Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryCode", deliveryCode);
        map.put("type", "deliveryTrace");
        Okhttp.post(Base, map, handler);

    }


    /**
     * 签收分类（签收页面调用的）
     */
    public static void signType(Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("type", "signType");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 签收（签收页面调用的）
     */
    public static void Sign(String deliveryCode,
                            String signTypeName,
                            String signUserName,
                            String imgStr,
                            String deliveryUid,
                            String deliveryUserName,
                            Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryCode", deliveryCode);
        map.put("signTypeName", signTypeName);
        map.put("signUserName", signUserName);
        map.put("imgStr", imgStr);
        map.put("deliveryUid", deliveryUid);
        map.put("deliveryUserName", deliveryUserName);
        map.put("type", "sign");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 退件（退件页面调用的）
     */
    public static void TJ(String deliveryCode,
                          String remark,
                          String imgStr,
                          String deliveryUid,
                          String deliveryUserName,
                          Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryCode", deliveryCode);
        map.put("remark", remark);
        map.put("imgStr", imgStr);
        map.put("deliveryUid", deliveryUid);
        map.put("deliveryUserName", deliveryUserName);
        map.put("type", "retrate");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 问题件（问题件页面调用的）
     */
    public static void WTJ(String deliveryCode,
                           String signTypeName,
                           String imgStr,
                           String deliveryUid,
                           String deliveryUserName,
                           Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryCode", deliveryCode);
        map.put("remark", signTypeName);
        map.put("imgStr", imgStr);
        map.put("deliveryUid", deliveryUid);
        map.put("deliveryUserName", deliveryUserName);
        map.put("type", "problem");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 问题件补充（问题件补充页面调用的）
     */
    public static void problemAdditional(String deliveryCode,
                                         String signTypeName,
                                         String imgStr,
                                         String deliveryUid,
                                         String deliveryUserName,
                                         Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryCode", deliveryCode);
        map.put("remark", signTypeName);
        map.put("imgStr", imgStr);
        map.put("deliveryUid", deliveryUid);
        map.put("deliveryUserName", deliveryUserName);
        map.put("type", "problemAdditional");
        Okhttp.post(Base, map, handler);

    }


    /**
     * 到件（到件页面调用的）
     */
    public static void reach(String deliveryCode,
                             String deliveryUid,
                             String deliveryUserName,
                             String networkName,
                             Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryCode", deliveryCode);
        map.put("deliveryUid", deliveryUid);
        map.put("deliveryUserName", deliveryUserName);
        map.put("networkName", networkName);
        map.put("type", "reach");
        Okhttp.post(Base, map, handler);

    }


    /**
     * 派件（派件页面调用的）
     */
    public static void send(String deliveryCode,
                            String deliveryUid,
                            String deliveryUserName,
                            Okhttp.Objectcallback handler) {

        Map<String, String> map = new HashMap<>();
        map.put("deliveryCode", deliveryCode);
        map.put("deliveryUid", deliveryUid);
        map.put("deliveryUserName", deliveryUserName);
        map.put("type", "send");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 派件（派件页面调用的）
     */
    public static void stateSearch(
            String deliveryUid,
            Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("deliveryUid", deliveryUid);
        map.put("type", "stateSearch");
        map.put("state", "4");

        Okhttp.post(Base, map, handler);

    }

    /**
     * 到件（到件页面调用的）
     */
    public static void stateSearch3(
            String deliveryUid,
            Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("deliveryUid", deliveryUid);
        map.put("type", "stateSearch");
        map.put("state", "3");
        Okhttp.post(Base, map, handler);

    }


    /**
     * 录件（录件页面调用的）
     */
    public static void add(
            String deliveryUid,
            String networkName,
            String deliveryUserName,
            String deliveryCode,
            String sendUserName,
            String sendPhone,
            String receiveName,
            String receivePhone,
            String receiveProvince,
            String receiveCity,
            String receiveDistrict,
            String receiveAddress,
            String networkId, String dj,
            Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("deliveryUid", deliveryUid);
        map.put("deliveryCode", deliveryCode);
        map.put("networkName", networkName);
        map.put("deliveryUserName", deliveryUserName);
        map.put("sendUserName", sendUserName);
        map.put("sendPhone", sendPhone);
        map.put("receiveName", receiveName);
        map.put("receivePhone", receivePhone);
        map.put("receiveProvince", receiveProvince);
        map.put("receiveCity", receiveCity);
        map.put("receiveDistrict", receiveDistrict);
        map.put("receiveAddress", receiveAddress);
        map.put("networkId", networkId);
        map.put("level", dj);
        map.put("type", "add");
        Okhttp.post(Base, map, handler);

    }

    /**
     * 录单查询（录单页面调用的）
     */
    public static void stateSearch1(
            String deliveryUid,
            Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("deliveryUid", deliveryUid);
        map.put("type", "stateSearch");
        map.put("state", "1");

        Okhttp.post(Base, map, handler);

    }
}
